package fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;

import com.example.administrator.projectmoudle_two.R;

import java.util.ArrayList;
import java.util.List;

import adapter.ListAdapter;

/**
 * Created by eyesee on 2017/6/4.
 */

public class MesuListView extends BaseFragment {

    public static MesuListView mMesuListView;
    public static final String TAG="MesuListView";
    private View mView;
    private ListView mListView;
    private List<String> mList;
    private Object mInfo;

    public static MesuListView getInstance(){
        if(mMesuListView==null){
            mMesuListView = new MesuListView();
        }
        return mMesuListView;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mView = View.inflate(mContext, R.layout.fragment_masurelist, null);
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        preparData();
        initView(mView);
        getInfo();
        return mView;
    }

    private void preparData() {
        mList = new ArrayList<>();
        for (int i = 0; i < 50; i++) {
            mList.add(i+"号item");
        }
    }

    private void initView(View view) {
        ListAdapter adapter = new ListAdapter(mList,mContext);
        mListView = ((ListView) view.findViewById(R.id.list));
        mListView.setHorizontalFadingEdgeEnabled(false);
        mListView.smoothScrollBy(180,100);
        mListView.setDividerHeight(0);
        mListView.setAdapter(adapter);
    }

    public void getInfo() {
        int height = mListView.getDividerHeight();
        Log.i(TAG, "getInfo:=="+height);
    }
}
